import { defineStore } from "pinia";
import { store } from "@/store";
import { GetMenuBy } from "@/api/stu/bigdataprocessing";
import qs from "qs";
export const stuUserStore = defineStore({
  id: "pure-stu",
  state: () => {
    return {
      BigDataProcessingTaskList: [],
      TaskDetails: {
        TaskDescription: undefined,
        name: ""
      },
      RoutingMenu: [], //路由菜单
      RoutingMenus: <any>[], //动态路由菜单,
      title:
        localStorage.getItem("title") +
        (localStorage.getItem("lable")
          ? "-" + localStorage.getItem("lable")
          : "")
    };
  },
  actions: {
    async openTask(row: number) {
      console.log("s001");
      const data = qs.stringify({ moudleId: row });
      const respone = await GetMenuBy(data);
      this.RoutingMenus = respone.data;
    },
    TITLE(title, lable) {
      if (lable) {
        this.title = title + "-" + lable;
      } else {
        this.title = title;
      }
      localStorage.setItem("title", this.title);
    }
  }
});
export function useUserStoreHook() {
  return stuUserStore(store);
}
